<script type="text/javascript" src="media/js/js_controls/js_date.js"></script><!-- Cargo el control datepicker -->
<script type="text/javascript">

	//List Configuration
	$j("#list_clinicalinformation").jqGrid({
		url:'clinicalinformation/list/<?php echo $parameters["id_patient"];?>',
		datatype:'json',
		mtype:'POST',
		colNames:[
		  			'Fecha',
		  			'Edad',
		  			'Altura',
		  			'Peso',
		  			'Observaciones',
		  			'Colesterol Total',
		  			'Colesterol HDL',
		  			'Colesterol LDL',
		  			'Trigliceridos',
		  			'Glucemia',
		  			'Presión Sistólica',
		  			'Presión Diastólica',
		  			'Paciente'
		],
		colModel:[
		          {
			          name:'information_date',
			          index:'infomation_date', 
			          width:30, 
			          editable: true,
			          editrules: {edithidden:true},
			          edittype: 'text'
				  },
		          {
			          name:'age',
			          index:'age',
			          width:30, 
			          editable: true,
			          hidden:false,
			          editrules: {edithidden:true},
			          align:"right"
			      },
		          {
			          name:'height', 
			          index:'height', 
			          width:20, 
			          editable: true,
			          hidden: true,
			          editrules: {edithidden:true},
			          align:"right"
			      },
		          {
			          name:'weight', 
			          index:'weight', 
			          width:20,
			          editable: true,
			          hidden: true,
			          editrules: {edithidden:true},
			          align:"right"
			      },
			      {
			          name:'observations', 
			          index:'observations', 
			          width:50,
			          editable: true,
			          hidden: true,
			          editrules: {edithidden:true},
			          edittype: 'textarea',
			          editoptions: { rows:'3', cols:'30'}
			      },
			      {
			    	  name:'total_cholesterol', 
			          index:'total_cholesterol', 
			          width:20,
			          editable: true,
			          hidden: true,
			          editrules: {edithidden:true},
			          align:"right"
				  },
				  {
					  name:'hdl', 
			          index:'hdl', 
			          width:20,
			          editable: true,
			          align:"right"
				  },    
				  {
					  name:'ldl', 
			          index:'ldl', 
			          width:20,
			          editable: true,
			          align:"right"
				  },
				  {
					  name:'triglycerides', 
			          index:'triglycerides', 
			          width:20,
			          editable: true,
			          align:"right"
				  },
				  {
					  name:'glucemic', 
			          index:'glucemic', 
			          width:20,
			          editable: true,
			          align:"right"
				  },
				  {
					  name:'systolic_pressure', 
			          index:'systolic_pressure', 
			          width:20,
			          editable: true,
			          hidden: true,
			          editrules: {edithidden:true},
			          align:"right"
				  },
				  {
					  name:'diastolic_pressure', 
			          index:'diastolic_pressure', 
			          width:20,
			          editable: true,
			          hidden: true,
			          editrules: {edithidden:true},
			          align:"right"
				  },
			      {
				      name: 'patient_id',
				      index: 'patient_id',
				      edittype: 'text',
				      editoptions: {value: <?php echo $parameters["id_patient"];?>},
				      width: 10,
				      editable: true,
				      hidden: true
				   }
		],
		pager:'#gridpager_clinicalinformation',
		loadtext: 'Cargando Información de Seguimiento ...',
		rowNum:10,
		rowList:[10],
		sortname:'information_date',
		sortorder:'desc',
		autowidth:true,
		viewrecords:true,
		onSelectRow:function(id){},
		editurl:'clinicalinformation/save/<?php echo $parameters["id_patient"];?>',
		scrollOffset:0
		//caption:'Actividades'
	});

	$j("#list_clinicalinformation").setGridWidth("650",true);
	$j("#list_clinicalinformation").setGridHeight(220);
		
	//Form editing
	$j("#list_clinicalinformation").jqGrid(
			'navGrid',
			'#gridpager_clinicalinformation',
			{
				edit:true,
				add:true,
				del:true,
				search:true
			},
			{
				width: 400,
				height: 320,
				closeAfterEdit: true,
				editCaption: "Modificar Información Clínica",
				afterShowForm:function(){
					DateControl.createDatePicker('#information_date','<?php echo $parameters["current_date"];?>',"Progressive");
					$j("#information_date").change(function(){
						$j("#age").val(DateControl.datediff('<?php echo $parameters["birthdate"];?>',this.value));
						return false;
					});
					//$j("#information_date").focus();
				},
				onclickSubmit:function() {  
					//$("#jsrs").empty(); 
				},
				onClose: function(){ 
					//$j("#information_date").focusout();
				} 
			},
			{
				width: 400,
				height: 320,
				closeAfterAdd: true,
				addCaption: "Nueva Información Clínica",
				afterShowForm:function(){
					DateControl.createDatePicker('#information_date','<?php echo $parameters["current_date"];?>',"Progressive");
					$j("#information_date").change(function(){
						$j("#age").val(DateControl.datediff('<?php echo $parameters["birthdate"];?>', this.value));
						return false;
					});
					//$j("#information_date").focus();
				},
				onclickSubmit:function() {  
					//$("#jsrs").empty(); 
				},
				onClose: function(){ 
					//$j("#information_date").focusout();
				}
			},
			{
				msg: "¿Desea eliminar la información clínica seleccionada?",
				caption: "Eliminar Información Clínica",
				width:350
			}
	);

	
	
	
</script>
